<!--
 * @Descripttion: 
 * @version: 
 * @Author: wtzhang
 * @Date: 2021-08-04 08:59:55
 * @LastEditors: wtzhang
 * @LastEditTime: 2021-08-04 13:38:36
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app"></div>
  <script src="../js/old_version/babel.min.js"></script>
  <script src="../js/old_version/react.development.js"></script>
  <script src="../js/old_version/react-dom.development.js"></script>
  <script type="text/babel">
    // 创建类组件
    class Weather extends React.Component {
      // 构造器
      // constructor(){
      //   super()
      //   this.state = {isHot: false}
      //   this.changeWeather = this.changeWeather.bind(this)
      // }
      // 初始化state
      state = {isHot: false}
      render() {
        let isHot = this.state.isHot
        return <h3 onClick={this.changeWeather}>今天天气很{isHot ? '热' : '凉爽'}！</h3>
      }
      // 自定义方法，要使用赋值语句的形式 + 箭头函数 
      changeWeather = () => {
        console.log(this);
        let isHot = this.state.isHot
        this.setState({
          isHot: !isHot
        })
      }
    }
    // 渲染到页面
    // ReactDOM.render(虚拟DOM, 容器)
    ReactDOM.render(<Weather />, document.getElementById('app'))
  </script>
</body>
</html>